package com.shameit.goodqrinfomanager;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.ViewDataBinding;

import com.example.mylibrary.BaseView;

import me.goldze.mvvmhabit.base.BaseActivity;
import me.goldze.mvvmhabit.base.BaseViewModel;

public abstract class BaseMVVMActivity<V extends ViewDataBinding, VM extends BaseViewModel> extends BaseActivity<V, VM> {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding.setVariable(BR.title, setTitle());
        initView();
        loadData();
    }

    protected void setToolBarBack(ViewDataBinding toolBarBack) {
        Toolbar toolbar = toolBarBack.getRoot().findViewById(R.id.toolbar);
        if (toolbar != null) {
            toolbar.setNavigationOnClickListener(view -> {
                onBackPressed();
            });
        }
    }

    protected abstract String setTitle();

    protected abstract void initView();
    protected abstract void loadData();
}
